package com.example.chupachups;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.view.Menu;
import android.widget.TextView;

public class MessageActivity extends Activity {

	private Intent intent;
	private String message;
	private ScrollTextView scrolltext;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		
		setContentView(R.layout.activity_message);
		
		scrolltext=(ScrollTextView) findViewById(R.id.scrolltext);
		startMessageScrolling();
        
        
	}
	
	private void startMessageScrolling() {
		// TODO Auto-generated method stub
		intent = getIntent();
		message = intent.getStringExtra("message");
		scrolltext.setText(message.toUpperCase());
        scrolltext.setTextColor(Color.rgb(216,5,5));
        scrolltext.setTranslationY(-30);
        scrolltext.startScroll();
        scrolltext.setOnScrollCompleteListener(new OnScrollCompleteListener(){
            @Override
            public void onScrollComplete() {
                // Handle the event here
        		Intent myIntent = new Intent(MessageActivity.this, MainActivity.class);
        		MessageActivity.this.startActivity(myIntent);
            }
        });
	}

	protected void onStop() {
		super.onStop();
    }

    protected void onRestart() {
    	super.onRestart();
    	startMessageScrolling();
    }

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_message, menu);
		return true;
	}

}
